
package com.ysd.common.utils;

/**
 * 〈请求返回的方法类型使用此类〉
 *
 * @author wangtao
 * @since 2020-07-11
 * @since 1.0.0
 */
public class Json {
	private String msg = "fail";
	private boolean suc = false;
	private Object result;

	//多种构造方法；
	public Json() {
	}

	public Json(String msg) {
		this.msg = msg;
	}

	public Json(String msg, Object result) {
		this.msg = msg;
		this.result = result;
	}

	public Json(String msg, Object result, boolean suc) {
		this.msg = msg;
		this.result = result;
		this.suc = suc;
	}

	public Json(Object result) {

		this.result = result;
	}

   //返回成功的方法；
	public static Json success(Object result) {
		//创建返回成功数据的对象
		return new Json("ok", result, true);
	}

	//f返回失败结果
	public static Json fail(String msg) {
		return new Json(msg, null, false);
	}

	//设置定义返回的结果集
	public static Json rs(String msg, Object result, boolean suc) {
		return new Json(msg, result, suc);
	}

	//属性的get和set方法；
	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public boolean isSuc() {
		return suc;
	}

	public void setSuc(boolean suc) {
		this.suc = suc;
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}

}